<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>layout 后台大布局 - Layui</title>
  <link rel="stylesheet" href="../layui/css/layui.css">
  	<style>
    .row {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
}

    .list-group {
        display: -ms-flexbox;
        display: flex;
        -ms-flex-direction: column;
        flex-direction: column;
        padding-left: 0;
        margin-bottom: 0;
    }
    .col {
        -ms-flex-preferred-size: 0;
        flex-basis: 0;
        -ms-flex-positive: 1;
        flex-grow: 1;
        max-width: 100%;
        position: relative;
        width: 100%;
        padding-right: 15px;
        padding-left: 15px;
    }
    .list-group-item:first-child {
        border-top-left-radius: .25rem;
        border-top-right-radius: .25rem;
    }
    .list-group-item {
        position: relative;
        display: block;
        padding: .75rem 1.25rem;
        margin-bottom: -1px;
        background-color: #fff;
        border: 1px solid rgba(0,0,0,.125);
    }
    .list-group-item:first-child {
  border-top-left-radius: 0.25rem;
  border-top-right-radius: 0.25rem;
}

.list-group-item:last-child {
  margin-bottom: 0;
  border-bottom-right-radius: 0.25rem;
  border-bottom-left-radius: 0.25rem;
}

.list-group-item:hover, .list-group-item:focus {
  z-index: 1;
  text-decoration: none;
}
.list-group-item.disabled, .list-group-item:disabled {
  color: #6c757d;
  pointer-events: none;
  background-color: #fff;
}

.list-group-item.active {
  z-index: 2;
  color: #fff;
  background-color: #007bff;
  border-color: #007bff;
}

</style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo">layui 后台布局</div>
    <!-- 头部区域（可配合layui已有的水平导航） -->
    <ul class="layui-nav layui-layout-left">
      <li class="layui-nav-item"><a href="">控制台</a></li>
      <li class="layui-nav-item"><a href="">商品管理</a></li>
      <li class="layui-nav-item"><a href="">用户</a></li>
      <li class="layui-nav-item">
        <a href="javascript:;">其它系统</a>
        <dl class="layui-nav-child">
          <dd><a href="">邮件管理</a></dd>
          <dd><a href="">消息管理</a></dd>
          <dd><a href="">授权管理</a></dd>
        </dl>
      </li>
    </ul>
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item">
        <a href="javascript:;">
          <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
          贤心
        </a>
        <dl class="layui-nav-child">
          <dd><a href="">基本资料</a></dd>
          <dd><a href="">安全设置</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item"><a href="">退了</a></li>
    </ul>
  </div>
  
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree"  lay-filter="test">
        <li class="layui-nav-item layui-nav-itemed">
          <a class="" href="javascript:;">所有商品</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;">列表一</a></dd>
            <dd><a href="javascript:;">列表二</a></dd>
            <dd><a href="javascript:;">列表三</a></dd>
            <dd><a href="">超链接</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item">
          <a href="javascript:;">解决方案</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;">列表一</a></dd>
            <dd><a href="javascript:;">列表二</a></dd>
            <dd><a href="">超链接</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item"><a href="">云市场</a></li>
        <li class="layui-nav-item"><a href="">发布商品</a></li>
      </ul>
    </div>
  </div>
  
  <div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">
		<div class="layui-row" style="margin-bottom: 10px;padding-left:15px;">
        <span class="layui-breadcrumb" lay-separator=">">
          <a href="{% url 'manage_project' %}">文集管理</a>
          <a><cite>导入文集</cite></a>
        </span>
    </div>
    <div class="layui-card-header" style="margin-bottom: 10px;">
      <span style="font-size:18px;">导入文集到MrDoc</span>
    </div>
    <div class="layui-row" >
        <button class="layui-btn layui-btn-normal layui-btn-sm" id="upload-zip"><i class="layui-icon layui-icon-upload"></i>导入.Zip文件</button>
    </div>
	    <div id="nested" class="row">
        <button onclick="getLevel()">aaa</button>
		<ul id="nestedDemo" class="list-group col nested-sortable">
			<li data-sortable-id="499" class="list-group-item" style="">万视电商数据助手脑图.<ul class="list-group nested-sortable"></ul></li>
			<li data-sortable-id="498" class="list-group-item" style="">《读懂一本书》思维导图.<ul class="list-group nested-sortable"></ul></li>
			<li data-sortable-id="500" class="list-group-item" style="">六类群体可得到慈善组织、红十字会优先帮扶_滚动新闻_中国政府网.<ul class="list-group nested-sortable"></ul></li>
		</ul>
    </div>
	</div>
	
  </div>
  
  <div class="layui-footer">
    <!-- 底部固定区域 -->
    © layui.com - 底部固定区域
  </div>
</div>
	<script src="../jquery/3.1.1/jquery.min.js"></script>
	<script src="../layui/layui.all.js"></script>
  <script src="./Sortable.js"></script>
<script>
    // Nested demo
    var nestedSortables = [].slice.call(document.querySelectorAll('.nested-sortable'));

    // Loop through each nested sortable element
    for (var i = 0; i < nestedSortables.length; i++) {
        new Sortable(nestedSortables[i], {
            group: {
                name:'nested',
                pull: function(event) {
                    //console.log(event);
                    var deep = event.el.parentNode.parentNode.parentNode.parentNode.className
                    // console.log(deep)
                    // please get deep
                    // console.log(deep)
                    if(deep == 'list-group nested-sortable') return false;
                    return true;
                },
            },
            animation: 150,
            fallbackOnBody: true,
			invertSwap:true,
            swapThreshold: 0.65,
            
        });
    }

    const nestedQuery = '.nested-sortable';
    const identifier = 'sortableId';
    const root = document.getElementById('nestedDemo');
    function serialize(sortable) {
      var serialized = [];
      var children = [].slice.call(sortable.children);
      for (var i in children) {
        var nested = children[i].querySelector(nestedQuery);
        serialized.push({
          id: children[i].dataset[identifier],
          children: nested ? serialize(nested) : []
        });
      }
      return serialized
    }

    console.log(serialize(root))
    function getLevel(){
        console.log(serialize(root))
    }
</script>
</body>
</html>